<?php
// 命令
// artisan make:request RegistRequest
namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
class RegistRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'=>'required',
            'email' => 'required|email',
            'password' => 'required|between:6,20|confirmed',
            'password_confirmation' => 'required|between:6,20',
        ];

    }
    // 自定义中文错误
    // 注意这里只能起名messages()方法
    // public function messages()
    // {
    //     return[
    //         'name.required'=>'昵称不能为空',
    //         'email.required'=>'邮箱不能为空',
    //         'password.required' => '密码不能为空',
    //         'password.between' => '密码长度要再6-20位之间',
    //         'password.confirmed' => '密码输入不一致!!!',
    //         'password_confirmation.required' => '确认密码不能为空',
    //         'password_confirmation.between' => '确认密码长度要在6-20位之间'
    //     ];
    // }
}
